Developer Documentation

QuickTime 4 API Documentation

Inside Macintosh: Sound

| Previous | Chapter contents | Chapter top | Section top | Next |

Creating and Removing Audio Sources

To write a sound output device component, you might need to define two routines that create and remove audio sources:

Your component needs to contain these functions only if, like the Apple Mixer, it can mix two or more audio channels into a single output stream. Sound components that operate on a single input stream only do not need to include these functions.

SoundComponentAddSource

A sound output device component that can mix multiple channel of audio data must implement the SoundComponentAddSource function to add a new sound source.

pascal ComponentResult SoundComponentAddSource
                                                              (ComponentInstance ti,
                     SoundSource *sourceID);
ti
A component instance that identifies your sound component.
sourceID
On exit, a source ID for the newly created source component chain.

DESCRIPTION

The SoundComponentAddSource function is called by the Sound Manager to create a new sound source. If your sound output device component can mix multiple channels of sound, it needs to define this function. Your SoundComponentAddSource function should call the Sound Manager function OpenMixerSoundComponent to create an new instance of the Apple Mixer component. The Apple Mixer component then creates a sound component chain capable of generating the type of data your sound output device component wants to receive.

The Apple Mixer also assigns a unique 4-byte source ID that identifies the new sound source and component chain. You can retrieve that source ID by calling the Apple Mixer's SoundComponentAddSource function. Your SoundComponentAddSource function should then pass that source ID back to the Sound Manager in the sourceID parameter.

Most sound components do not need to implement the SoundComponentAddSource function. Only sound components that can handle more than one source of input need to define it.

SPECIAL CONSIDERATIONS

The SoundComponentAddSource function is called at noninterrupt time.

RESULT CODES

Your SoundComponentAddSource function should return noErr if successful or an appropriate result code otherwise.

SEE ALSO

See [link] for a description of OpenMixerSoundComponent .

SoundComponentRemoveSource

A sound output device component that implements the SoundComponentAddSource function must also implement the SoundComponentRemoveSource function to remove sound sources.

pascal ComponentResult SoundComponentRemoveSource
                                                              (ComponentInstance ti,
                     SoundSource sourceID);
ti
A component instance that identifies your sound component.
sourceID
A source ID for the source component chain to be removed.

DESCRIPTION

Your SoundComponentRemoveSource function is called by the Sound Manager to remove the existing sound source specified by the sourceID parameter. Your SoundComponentRemoveSource function should do whatever is necessary to invalidate that source and then call through to the Apple Mixer's SoundComponentRemoveSource function.

Most sound components do not need to implement the SoundComponentRemoveSource function. Only sound components that can handle more than one source of input need to define it.

SPECIAL CONSIDERATIONS

Your SoundComponentRemoveSource function is always called at noninterrupt time.

RESULT CODES

Your SoundComponentRemoveSource function should return noErr if successful or an appropriate result code otherwise.


© 1999 Apple Computer, Inc.

| Previous | Chapter contents | Chapter top | Section top | Next |